<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--JSTL--%>
<h1>
    <c:out value="${pageContext.servletContext.contextPath}"></c:out>
</h1>

<%
    // 绑定list集合到请求域对象中
    List<String> list = new ArrayList<>();
    list.add("Java");
    list.add("Python");
    list.add("JavaScript");

    // 绑定数据到请求域
    request.setAttribute("list", list);
%>

<c:if test="${!empty list}" var="obj">
    <h1>数据不为null</h1>
    <h1>${obj}</h1>
</c:if>

<c:forEach items="${list}" var="li" varStatus="vs">
    <h1>${li}长度为：${li.length()}</h1>
    <h3>当前元素的索引为：${vs.index}</h3>
</c:forEach>
</body>
</html>
